<%= content_for :title, "Clusters" %>
<%= turbo_stream_from [:clusters, current_account] %>

<div>
  <div class="flex items-center justify-between">
    <h3 class="text-lg font-medium">Clusters</h3>
  </div>

  <div class="mt-5">
    <div aria-label="Card" class="card card-bordered bg-base-100">
      <div class="card-body">
        <div class="text-right px-5 pt-5">
          <div class="flex items-center justify-end gap-2">
            <%= link_to new_cluster_path, title: t("scaffold.new.title", model: "Cluster") do %>
              <button class="btn btn-primary btn-sm">
                <iconify-icon icon="lucide:plus" height="16"></iconify-icon>
                <span class="hidden sm:inline">New Cluster</span>
              </button>
            <% end %>

            <% if current_account.stack_manager&.portainer? %>
              <%= button_to sync_clusters_stack_manager_path, class: "btn btn-outline btn-sm" do %>
                <iconify-icon icon="lucide:refresh-ccw" height="16"></iconify-icon>
                <span class="hidden sm:inline">Sync Clusters</span>
              <% end %>
            <% end %>
          </div>

        </div>
        <%= tag.div id: ("clusters" if @pagy.pages == 1) do %>

          <%= render "clusters/index", clusters: @clusters, cached: true %>

          <div class="hidden only:block text-center">
            <p class="mb-4 h3">Create your first Cluster</p>
            <%= link_to t("scaffold.new.title", model: "Cluster"), new_cluster_path, class: "btn btn-primary" %>
          </div>
        <% end %>
      </div>
    </div>
  </div>

  <%= render 'shared/pagination', pagy: @pagy %>
</div>
